package com.sptpc.demo.global.exception;

import com.sptpc.demo.global.response.GlobalResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(BusinessException.class)
    public GlobalResponse handleBusinessException(BusinessException exception){
        return GlobalResponse.builder()
                .code(exception.getErrorCode().getCode())
                .msg(exception.getMessage())
                .data(null)
                .build();


    }
}
